package com.lsu.memento.experiment;

/**
 * 发起者
 *
 * @Author wang suo
 * @Date 2021/1/4 0004 22:10
 * @Version 1.0
 */
public class Originator {
    private State state;

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    /**
     * 创建备忘录对象
     *
     * @return 返回备忘录对象
     */
    public Memento createMemento() {
        return new Memento(this.state);
    }

    /**
     * 重载位置
     *
     * @param memento 备忘录对象
     */
    public void restoreMemento(Memento memento) {
        this.setState(memento.getState());
    }
}
